all files / infiniteScroll/ infiniteScroll.vue

53.33% Statements 8/15
50% Branches 4/8
50% Functions 1/2
33.33% Lines 3/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                1× 1×                                                            
//
//
//
//
//
//
//
 
import circular from '../internal/circular'
import Scroll from '../internal/scroll'
export default {
  name: 'mu-infinite-scroll',
  mixins: [Scroll],
  props: {
    loading: {
      type: Boolean,
      default: false
    },
    loadingText: {
      type: String,
      default: '正在加载。。。'
    }
  },
  methods: {
    onScroll () {
      if (this.loading) return
      const scroller = this.scroller
      let h = scroller.scrollHeight - scroller.scrollTop - 5
      let sh = scroller.offsetHeight
      if (h <= sh) {
        this.$emit('load')
      }
    }
  },
  components: {
    circular
  }
}